package cn.alusiaor.nacosdiscoveryclientprovider.controller;


import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RefreshScope
public class TestController {

    @Value("${multi1:null}")
    private String multi1;

    @Value("${multi2:null}")
    private String multi2;

    @GetMapping("/hello")
    public String hello(@RequestParam String name) {
        log.info("invoked name = " + name);
        return "hello " + name;
    }

    @GetMapping("/multi")
    public String multiConfig() {
        return String.format("multi1: %s multi2: %s", multi1, multi2);
    }

    @GetMapping("/index")
    public Object index(Authentication authentication) {
        return authentication;
    }
}
